/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 收费管理-收费管理制度的表内容
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   ChargemanagementController.java for com.pengtu.gsj.controller.checker.sfgl    </p>
 * 
 * <p>最后修改 : $: 2017年7月24日-上午9:38:22 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.controller.checker.sfgl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.pengtu.gsj.controller.base.CheckTableBaseController;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.app.Sysmenu;
import com.pengtu.gsj.entity.check.CheckProject;
import com.pengtu.gsj.entity.check.CheckTable;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.check.CheckTableService;
import com.pengtu.gsj.service.system.SystemManageService;
import com.pengtu.gsj.utils.web.SpringMvcUtils;

/**
 * 
 * ChargeManagementController
 * 收费管理-收费管理制度的表内容
 * 2017年7月24日 上午9:38:22
 * author：heyong
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("chargeManagement")
public class ChargeManagementController extends CheckTableBaseController {
	@Autowired
	private CheckTableService checkTableService;
	@Autowired
	private SystemManageService systemManageService;
	
	/**
	 * 
	 * goToPage:
	 * 适用:跳转到收费管理检查表页面
	 * @param model
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@Token(save = true)
	@RequestMapping("show")
	public String goToPage(Model model) {
		//获取提示信息并返回到页面显示
		String msg = SpringMvcUtils.getParameter("msg");
		if (StringUtils.isNotEmpty(msg)) {
			model.addAttribute("msg", msg);
		}
		return "check/sfgl/chargeManagement_list";
	}
	
	/**
	 * 保存
	 * saveMaintenanceMony:
	 * 适用:
	 * @param checkTable
	 * @param checkProject
	 * @param attributes
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping("save")
	@Token(remove = true)
	public String saveChargeManagement(@ModelAttribute CheckTable checkTable, @ModelAttribute CheckProject checkProject, RedirectAttributes attributes){
		checkTable.setCheckProject(checkProject);
		checkTable.setTableFull(2.00); //设置当前检查表格的总分
		checkTableService.save(checkTable);
		attributesParams(checkTable, attributes);
		return "redirect:/chargeManagement/show.do";
	}
	
	/**
	 * 
	 * getSearchMap:
	 * 适用:查询，收费管理制度页面进入后，默认查询
	 * @param checkProject
	 * @param sysmenu
	 * @return
	 * @throws Exception 
	 * @exception 
	 * @since  1.0.0
	 */
	@ResponseBody
	@RequestMapping(value = "search", produces = "application/json; charset=utf-8")
	public Map<String, Object> getSearchMap(@ModelAttribute CheckProject checkProject, @ModelAttribute Sysmenu sysmenu) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		List<Attachment> attmentList = new ArrayList<Attachment>();
		//附件查询
		attmentList = systemManageService.getCheckAttachments(checkProject, sysmenu == null ? "" : sysmenu.getTag());
		map.put("attment", attmentList);
		return map;
	}
}
